//
//  FoodListTableViewCell.m
//  Menu
//
//  Created by Lynn-Shin on 15/7/2.
//  Copyright (c) 2015年 lijiangang. All rights reserved.
//

#import "FoodListTableViewCell.h"

@implementation FoodListTableViewCell

-(void)dealloc{
    
    [_titleLabel release];
    [_collectLabel release];
    
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews{
    
    self.foodImage = [[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 120, 80)];
    self.foodImage.backgroundColor = [UIColor redColor];
    [self addSubview:self.foodImage];
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(150, 20, 200, 30)];
//    self.titleLabel.backgroundColor = [UIColor lightGrayColor];
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:self.titleLabel];
    
    self.stepLabel = [[UILabel alloc] initWithFrame:CGRectMake(150, 55, 80, 25)];
    self.stepLabel.font = [UIFont systemFontOfSize:13];
    [self addSubview:self.stepLabel];
    
    self.collectLabel = [[UILabel alloc] initWithFrame:CGRectMake(150, 80, 80, 25)];
//    self.collectLabel.backgroundColor = [UIColor lightGrayColor];
    self.collectLabel.font = [UIFont systemFontOfSize:13];
    self.collectLabel.textColor = [UIColor grayColor];
    [self addSubview:self.collectLabel];
    
    [self.foodImage release];
    [self.titleLabel release];
    [self.stepLabel release];
    [self.collectLabel release];
}

-(void)setFoodList:(FoodList *)foodList{
    
    if (_foodList != foodList) {
        
        [_foodList release];
        _foodList = [foodList retain];
    }
    
    [self.foodImage sd_setImageWithURL:[NSURL URLWithString:foodList.img]];
    
    self.titleLabel.text = [NSString stringWithFormat:@"%@", foodList.n];
    self.stepLabel.text = [NSString stringWithFormat:@"%ld %@",foodList.stc, @"个步骤"];
    self.collectLabel.text = [NSString stringWithFormat:@"%@ %ld", @"收藏",foodList.fc];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
